// 开发环境
const path = require('path')
const webpack = require('webpack')
const { merge } = require('webpack-merge')
const common = require('./webpack.common')

module.exports = merge(common, {
  target: 'web', // webpack5.x 加上之后热更新才有效果
  mode: 'development',
  devtool: 'eval-cheap-module-source-map',
  output: {
    filename: 'js/[name].bundle.js', // 输出文件
    path: path.join(__dirname, 'dist') // 输出文件目录
  },
  devServer: {
    hot: true, // 开启热替换
    open: true, // 自动打开，类似 --open
    port: 9527
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ]
})
